import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


export default new Vuex.Store({
  state: {
    cartlist:[]
  },
  mutations: {
    addcart(state,payload){
      let oldProduct = state.cartlist.find(item => item.iid === payload.iid );

      if(oldProduct){
        oldProduct.count += 1
      }else{
        payload.count = 1;
        payload.checked = true
        state.cartlist.push(payload)
      }

    }
  },
  actions: {
  },
  modules: {
  }
})
